home *** CD-ROM | disk | FTP | other *** search
File List | 1987-04-17 | 3.3 KB | 180 lines |
- Rem --> Following definitions are for XMODEM <--
- Soh=1 ! Start Of Header
- Eot=4 ! End Of Transmission
- Ack=6 ! ACKnowledge
- Nak=21 ! Negative AcKnowledge
- Can=24 ! CANcel
- Return
- '
- Procedure Xmodem_receive(Filename$)
- Oldx%=Crscol
- Oldy%=Crslin
- Void Xbios(21,0)
- Sget Screen1$
- Cls
- '
- Xmodem_part1:
- Open "O",#1,Filename$
- Print At(35,1);Rv1$;"XMODEM receive";Rv0$
- Print
- Print At(10,3);"Receiving: ";Green$;Upper$(Filename$);Char$
- Print
- Block%=1
- Try%=1
- '
- Xmodem_part2:
- @Clear_modem
- Void Bios(3,1,Nak)
- Time_out=0
- '
- Xmodem_part3:
- Print At(10,7);Rv1$;"Block-->";Rv0$;Block%;" ";Rv1$;"Try-->";Rv0$;Try%
- '
- Xmodem_part4:
- Print At(10,9);"Time out:";Time_out
- '
- Xmodem_part5:
- Stat!=Bios(1,1)
- If Stat!=0 Then
- Goto Xmodem_part6
- Else
- Goto Xmodem_part7
- Endif
- '
- Xmodem_part6:
- Inc Time_out
- If (Time_out/128)=(128*10) Then
- Goto Xmodem_part11
- Endif
- If (Time_out/128)=Int(Time_out/128) Then
- Goto Xmodem_part2
- Else
- Goto Xmodem_part5
- Endif
- '
- Xmodem_part7:
- Da%=Bios(2,1)
- If Da%=Soh Then
- Goto Xmodem_part8
- Endif
- If Da%=Eot Then
- Goto Xmodem_part12
- Endif
- If Da%=Can Then
- Goto Xmodem_part11
- Endif
- Goto Xmodem_part6
- '
- Xmodem_part8:
- Block_numb%=0
- Block_comp%=0
- Block_numb%=Bios(2,1)
- Block_comp%=Bios(2,1)
- Print At(10,11);"Block number: ";Block_numb%;" ";"Block Compliment: ";Block_comp%
- Print At(24,13);Space$(20)
- Check%=0
- Block$=""
- Checksum%=0
- Print At(10,13);"Byte received:";
- For Byte=1 To 128
- Print At(24,13);Byte
- Da%=0
- Byte_data:
- Abort$=Inkey$
- Exit If Abort$=Chr$(24)
- If Bios(1,1) Then
- Da%=Bios(2,1)
- Check%=Check%+Da%
- Block$=Block$+Chr$(Da%)
- Else
- Goto Byte_data
- Endif
- Next Byte
- Print At(24,13);"Got 128 bytes!"
- If Abort$=Chr$(24) Then
- Goto Xmodem_part11
- Else
- Checksum%=Check% And 255
- Endif
- Check:
- Abort$=Inkey$
- If Abort$=Chr$(24) Then
- Goto Xmodem_part11
- Endif
- Check_sum%=0
- Print At(10,15);Space$(50)
- Print At(10,15);"Awaiting checksum.........."
- If Bios(1,1)=-1 Then
- Check_sum%=Inp(1)
- Else
- Goto Check
- Endif
- Print At(10,15);Space$(50)
- Print At(10,15);"Our check: ";Checksum%;" Their check:";Check_sum%
- If Checksum%=Check_sum% Then
- Goto Xmodem_part9
- Else
- Goto Xmodem_part10
- Endif
- '
- Xmodem_part9:
- Print #1,Block$;
- Try%=1
- Inc Block%
- Time_out=0
- B_out=0
- @Clear_modem
- Out 1,Ack
- Goto Xmodem_part3
- '
- Xmodem_part10:
- Inc Try%
- If Try%>10 Then
- Goto Xmodem_part11
- Else
- @Clear_modem
- Endif
- Goto Xmodem_part2
- '
- Xmodem_part11:
- Out 1,Can
- Out 1,Can
- Out 1,Can
- Close #1
- Kill Filename$
- Print At(10,17);"Status: ";Red$;"XMODEM CANCELLED -- ";Char$;
- Print Green$;Upper$(Filename$);Char$;" deleted."
- Print At(28,20);"PRESS ANY KEY"
- Void Inp(2)
- Goto Xmodem_end
- '
- Xmodem_part12:
- Out 1,Ack
- Close #1
- Print At(10,17);"Status: ";Green$;"XMODEM COMPLETE. ";Red$;
- Print Upper$(Filename$);
- Print Char$;" received."
- Print At(28,20);"PRESS ANY KEY"
- Void Inp(2)
- Goto Xmodem_end
- '
- Xmodem_end:
- Cls
- @Clear_modem
- Sput Screen1$
- Clr Screen1$
- Print At(Oldx%,Oldy%);
- Void Xbios(21,1)
- Return
- '
- Procedure Clear_modem
- Rem --> Clears the modem of any extraneous data <--
- Do
- Test!=Bios(1,1)
- Exit If Test!=0
- Void Inp(1)
- Loop
- @Clear_iorec_buffer(1024)
- Return
- '
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə